// 配置路由
import { createRouter, createWebHistory } from 'vue-router';
import Films from '../views/Films.vue';
import Nowplaying from '../views/films/Nowplaying.vue';

const routes = [
    {
        path: '/films',
        component: Films,
        redirect: '/films',
        children: [  //嵌套路由
            {
                path: '/films/nowplaying',
                component: Nowplaying,
            },
            {
                path: 'comingsoon',//注意不要加斜杠, 不加斜杠它会自动补齐前缀
                component: () => import('../views/films/Comingsoon.vue')
            },
            {
                path: '/films',
                redirect: '/films/nowplaying'
            }
        ]
    },
    {
        path: '/cinemas',
        component: () => import('../views/Cinemas.vue')
    },
    {
        path: '/detail/:myid',
        name: 'detail',
        component: () => import('../views/Detail.vue'),

    },
    {
        name: 'centers',
        alias: '/wode',
        path: '/centers',
        component: () => import('../views/Centers.vue'),
        meta: {
            requiredAuth: true
        }
    },
    {
        name: 'Login',
        path: '/login',
        component: () => import('../views/Login.vue'),
    },
    {
        path: '/',
        redirect: '/films',
    },
    {
        path: '/:pathMatch(.*)*',
        component: () => import('../views/NotFound.vue'),
    }

];
const router = createRouter({
    history: createWebHistory(),
    routes,//routes:routes的缩写
});

export default router;